package terra.network.packet.server;

import org.jboss.netty.buffer.ChannelBuffer;

import terra.network.packet.Packet;

public class TileInfo extends Packet {

	public byte type;
	public int x, y;
	public int id;
	public int hp = 0;
	public float mass = 0;
	
	public TileInfo() {
	}

	public TileInfo(int i, int j, byte typeGround) {
		x = i;
		y = j;
		type = typeGround;
	}

	@Override
	public ChannelBuffer toBuffer() {
		ChannelBuffer buf = getNewBuffer();
		buf.writeByte(getId());	
		buf.writeInt(id);
		buf.writeInt(x);
		buf.writeInt(y);
		buf.writeInt(hp);
		buf.writeFloat(mass);
		buf.writeByte(type);		
		return buf;
	}

	@Override
	public Packet fromBuffer(ChannelBuffer buf) {
		id = buf.readInt();
		x = buf.readInt();
		y = buf.readInt();
		hp = buf.readInt();
		mass = buf.readFloat();
		type = buf.readByte();
		return this;
	}

	@Override
	public int getLength() {
		return 22;
	}

	@Override
	public boolean isDynamicLength() {
		return false;
	}

	@Override
	public byte getId() {
		return 16;
	}
	
	@Override
	public byte getPriority() {
		return PRIOR_LOW;
	}

}
